﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using lgmkr;

namespace cpmntctrl
{
    public class ShowMessage
    {
        private static readonly LogMaker ALogMaker=new LogMaker();

        public static string Warningmessage { get; set; }

        public static string Errormessage { get; set; }

        public static void ShowWarningMessage(TextBox aTextBox)
        {
            if (aTextBox.Text.Length==0)
            {
                Warningmessage = "Талааны толтургула!!!";
                if (MessageBox.Show(Warningmessage, "Warning", MessageBoxButtons.OKCancel) == DialogResult.OK)
                    aTextBox.Focus();
            }
            ALogMaker.Error = Warningmessage + " " + aTextBox.Name+" "+aTextBox.Parent.Name + " Формасы";
            ALogMaker.NowDateTime = DateTime.Now;
            ALogMaker.PrintLog();
        }
        public static void ShowWarningMessage(params TextBox[] aTextBox)
        {
            foreach (var textBox in aTextBox.Where(textBox => textBox.Text.Length == 0))
            {
                Warningmessage = "Талааларды толтургула!!!";
                if (MessageBox.Show(Warningmessage, "Warning", MessageBoxButtons.OKCancel) == DialogResult.OK)
                {
                    textBox.Focus();
                    ALogMaker.Error = Warningmessage + " " + textBox.Name+" "+textBox.Parent.Name + " Формасы";
                    ALogMaker.NowDateTime = DateTime.Now;
                    ALogMaker.PrintLog();  
                }
                break;
            }
        }

        public static void ShowWarningMessage(ComboBox aComboBox)
        {
            if (aComboBox.SelectedValue==null)
            {
                Warningmessage = "Талааны толтургула!!!";
                if (MessageBox.Show(Warningmessage, "Warning", MessageBoxButtons.OKCancel) == DialogResult.OK)
                    aComboBox.Focus();
            }
            ALogMaker.Error = Warningmessage + " " + aComboBox.Name + " " + aComboBox.Parent.Name + " Формасы";
            ALogMaker.NowDateTime = DateTime.Now;
            ALogMaker.PrintLog();
        }
        public static void ShowWarningMessage(params ComboBox[] aComboBox)
        {
            foreach (var comboBox in aComboBox)
            {
                Warningmessage = "Талааларды толтургула!!!";
                if (MessageBox.Show(Warningmessage, "Warning", MessageBoxButtons.OKCancel) == DialogResult.OK)
                {
                    comboBox.Focus();
                    ALogMaker.Error = Warningmessage + " " + comboBox.Name + " " + comboBox.Parent.Name + " Формасы";
                    ALogMaker.NowDateTime = DateTime.Now;
                    ALogMaker.PrintLog();
                }
                break;
            }
        }
    }

} 
